package controllers.account;

import static play.data.Form.form;
import play.data.DynamicForm;
import play.data.Form;
import play.libs.F.Function0;
import play.mvc.Controller;
import play.mvc.Result;
import prefix.util.JPAUtil;
import repository.AbstractRepository;
import repository.ActorRepository;
import service.ActorService;
import web.entity.User;

public class Account extends Controller {
    final static Form<User> regForm = form(User.class);

    public static Result checkEmail() {

        DynamicForm request = form().bindFromRequest();
        final String email = request.get("inputEmail");
        System.out.println("-------------" + email);
        ActorService actor = null;
        try {

            actor = ActorRepository.getActorServiceByEmail(email);

        } catch (Throwable t) {
            t.printStackTrace();
            // handle the exception
        } finally {
            JPAUtil.closeEM();
        }
        if (actor != null) {
            return ok("false");
        }
        return ok("true");
        
        
    }
}
